#include <cmath>
#include <iostream>
#include "modesDecision.h"

float* modesDecison::dc(float coff[][16][16], int m) 
{
    float *temp = new float[4];
    
    temp[0] = coff[m][0][0];
    temp[1] = coff[m-16][0][0];
    temp[2] = coff[m-17][0][0];
    temp[3] = coff[m-1][0][0];
    
    return temp;
        
}

int modesDecision::modes(float *dc)
{
    float average=0;
    float S=0;
    
    average = (dc[0]+dc[1]+dc[2]+dc[3])/4;
    
    for(int i=0; i<4; i++)
    S += abs(dc[i]-average);
    
    if(S < th) {
       MODE = 16;
       std::cout <<" The mode is 16x16 " << std::endl;
    }
    else {
       MODE = 4;
       std::cout <<" The mode is 4x4 " << std::endl;
    }
    
    return MODE;
}